//
//  BFMessageController.m
//  beifang
//
//  Created by Apple on 17/4/12.
//  Copyright © 2017年 郭凯. All rights reserved.
//

#import "BFMessageController.h"
#import "BFAudioRecorder.h"
#import "BFAudioPLayer.h"
@interface BFMessageController ()
@property(nonatomic,strong)BFAudioRecorder *audioRecorder;
@property (nonatomic,strong) BFAudioPLayer* audioPlayer;
@end

@implementation BFMessageController
-(BFAudioRecorder *)audioRecorder{
    if (!_audioRecorder) {
        _audioRecorder = [[BFAudioRecorder alloc]init];
    }
    return _audioRecorder;
}

-(BFAudioPLayer *)audioPlayer{
    if (!_audioPlayer) {
        _audioPlayer = [[BFAudioPLayer alloc]init];
    }
    return _audioPlayer;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"消息";
}
/**开始录音*/
- (IBAction)startRecord:(id)sender {
    NSLog(@"开始录音");
    [self.audioRecorder startRecord];
}
/**暂停录音*/
- (IBAction)pause:(id)sender {
    NSLog(@"暂停录音");
    [self.audioRecorder pasueRecord];

}
/**恢复录音*/
- (IBAction)resume:(id)sender {
    NSLog(@"恢复录音");
    [self.audioRecorder resumeRecord];

}
/**结束录音*/
- (IBAction)stop:(id)sender {
    NSLog(@"结束录音");
    [self.audioRecorder stopRecord];
}

- (IBAction)playAudio:(id)sender {
//    NSURL *url = [NSURL fileURLWithPath:self.audioRecorder.audioPath];
    NSString *path =  [[NSBundle mainBundle]pathForResource:@"test.mp3" ofType:nil];
    NSURL *url = [NSURL fileURLWithPath:path];
    [self.audioPlayer playAudio:url];
}
- (IBAction)playOnlinAudio:(id)sender {
    NSURL *url = [NSURL URLWithString:@"http://sc1.111ttt.com/2016/1/12/10/205102159306.mp3"];
    [self.audioPlayer playOnlineAudio:url];
}
- (IBAction)pausePlay:(id)sender {
    
    [self.audioPlayer pasue];
}
- (IBAction)stopPlay:(id)sender {
    [self.audioPlayer stop];
}
- (IBAction)resumePlay:(id)sender {
    [self.audioPlayer resume];
}

@end
